package work.mediway.mdm.biz.service.biz.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import org.springframework.stereotype.Service;

import java.util.List;

import cn.hutool.core.util.StrUtil;
import work.mediway.mdm.biz.service.biz.SsDataQualityLogService;
import work.mediway.mdm.core.enums.DataQualityVerifyEnum;
import work.mediway.mdm.biz.entity.biz.SsDataQualityLog;
import work.mediway.mdm.biz.mapper.biz.SsDataQualityLogMapper;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2022/7/13
 */
@Service
public class SsDataQualityLogServiceImpl extends ServiceImpl<SsDataQualityLogMapper, SsDataQualityLog> implements SsDataQualityLogService {

    @Override
    public List<SsDataQualityLog> selectDataQualityLog(SsDataQualityLog dataQualityLog) {
        List<SsDataQualityLog> dataQualityLogs = this.baseMapper.selectDataQualityLog(dataQualityLog);
        for (SsDataQualityLog qualityLog : dataQualityLogs) {
            if (StrUtil.equals(qualityLog.getQualityType(), DataQualityVerifyEnum.N.name())) {
                qualityLog.setDiffCount(StrUtil.isNotBlank(qualityLog.getMissingDataValue()) ? Integer.valueOf(qualityLog.getMissingDataValue()) : null);
            } else {
                qualityLog.setDiffCount(StrUtil.isNotBlank(qualityLog.getErrorDataValue()) ? Integer.valueOf(qualityLog.getErrorDataValue()) : null);
            }
        }
        return dataQualityLogs;
    }
}
